package com.letao.controller;

import com.letao.common.pojo.EasyUITreeNode;
import com.letao.common.pojo.LetaoResult;
import com.letao.service.ContentCategrayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by ac on 2017/1/18.
 */
@Controller
@RequestMapping("/content/category")
public class ContentCategoryController {
    @Autowired
    private ContentCategrayService service;

    @ResponseBody
    @RequestMapping("/list")
    public List<EasyUITreeNode> getCategoryList(@RequestParam(value = "id", defaultValue = "0") Long parentId){
        return service.getContentCategray(parentId);
    }

    @ResponseBody
    @RequestMapping("/create")
    public LetaoResult saveCategory(@RequestParam Long parentId, @RequestParam String name){
        return service.insertContetCategory(name, parentId);
    }

    @ResponseBody
    @RequestMapping("/update")
    public LetaoResult updateCategory(@RequestParam Long id, @RequestParam String name){
        return service.upadteContentCategory(name, id);
    }

    @ResponseBody
    @RequestMapping("/delete")
    public LetaoResult removve(@RequestParam Long id){
        return service.deleteCcontentCategory(id);
    }




}
